package com.wd.live.view.adpater;

import android.content.Context;
import android.view.View;
import android.widget.ImageView;
import android.widget.Toast;

import com.bumptech.glide.Glide;
import com.wd.live.R;
import com.wd.live.bean.ContellationBeen;
import com.wd.live.bean.SignBean;
import com.zhy.adapter.recyclerview.CommonAdapter;
import com.zhy.adapter.recyclerview.base.ViewHolder;

import java.util.ArrayList;
import java.util.List;

public class ConstellCelectAdapter extends CommonAdapter<ContellationBeen.ResultBean> {
    private int[] imageUrls={R.mipmap.signs_01,R.mipmap.signs_02,R.mipmap.signs_03,R.mipmap.signs_04,R.mipmap.signs_05
    ,R.mipmap.signs_06,R.mipmap.signs_07,R.mipmap.signs_08,R.mipmap.signs_09,R.mipmap.signs_10,R.mipmap.signs_11,R.mipmap.signs_12
    };
    private int[] image={R.mipmap.sign_01,R.mipmap.sign_02,R.mipmap.sign_03,R.mipmap.sign_04,R.mipmap.sign_05
            ,R.mipmap.sign_06,R.mipmap.sign_07,R.mipmap.sign_08,R.mipmap.sign_09,R.mipmap.sign_10,R.mipmap.sign_11,R.mipmap.sign_12
    };
    ArrayList<Integer> list=new ArrayList<>();
    public ConstellCelectAdapter(Context context, int layoutId, List<ContellationBeen.ResultBean> datas) {
        super(context, layoutId, datas);
    }


    @Override
    protected void convert(ViewHolder holder, ContellationBeen.ResultBean resultBean, int position) {
        ImageView imgUrl = holder.getView(R.id.contellimg);
        Glide.with(mContext).load(imageUrls[position]).into(imgUrl);
        imgUrl.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                list.add(image[position]);
                if(list.size()>1){
                    Toast.makeText(mContext, "只能选择一个星座哦", Toast.LENGTH_SHORT).show();
                }else{
                Glide.with(mContext).load(image[position]).into(imgUrl);
                if(callBack!=null){
                    callBack.Call(resultBean,position);
                }
                }
            }
        });

    }
    public interface CallBack{
        void Call(ContellationBeen.ResultBean resultBean,int position);
    }
    private CallBack callBack;

    public void setCallBack(CallBack callBack) {
        this.callBack = callBack;
    }
}
